<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ page session="true" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Fresh Direct</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
    <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
<!-- DataTables CSS -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.css">

		<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
		<script type="text/javascript" language="javascript" src="//cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.js"></script>

	
	
	<style type="text/css" class="init">

	</style>
		
	
	<script type="text/javascript" language="javascript" >


$(document).ready(function() {
    $('#topclients').dataTable( {
        
        "ordering": false,
        "info":     false
        
    } );
} );
	</script>

</head>
<body>
 <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
     url="jdbc:mysql://localhost:3306/freshDirect"
     user="root"  password="admin"/>

<sql:query dataSource="${snapshot}" var="result">
call topclients();
</sql:query>   
<nav class="navbar navbar-default" role="navigation">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
        <a class="navbar-brand" href="${contextPath}"><img width="100" src="https://www.freshdirect.com/media/images/navigation/global_nav/fd_logo_on.gif"></img></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
          <li><h4>Welcome to FreshDirect! Administrator Page</h4></li>	
      </ul>
      <ul class="nav navbar-nav navbar-right">

          <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Administrator <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="${contextPath}/admin/home">Home</a></li>
                <li><a href="${contextPath}/admin/topclients">Top Clients</a></li>
                <li><a href="${contextPath}/admin/newproduct">Manage Products</a></li>
                <li><a href="${contextPath}/admin/viewusers">View Users</a></li>
                <li class="divider"></li>
                <li><a href="${contextPath}/admin/signout">Sign Out</a></li>
              </ul>
            </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<div class="container">
<div class="row">
        <nav class="navbar navbar-default" role="navigation" style="background-color: #728d4b; border-radius: 10px;">
  <div class="container-fluid" style="background-color: #728d4b; border-radius: 10px; ">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" style="background-color: #728d4b" id="bs-example-navbar-collapse-2">
      <ul class="nav navbar-nav" style="background-color: #728d4b">
        <li style="background-color: #728d4b"><a style="background-color: #728d4b; color:white; font-size: 18px; font-weight: bold; font-family: 'Oswald', sans-serif;" href="${contextPath}/admin/home">Home</a></li>
        <li><a style="color:white; font-size: 18px; font-weight: bold; font-family: 'Oswald', sans-serif; " href="${contextPath}/admin/topclients">Top Clients</a></li>
        <li><a style="color:white; font-size: 18px; font-weight: bold; font-family: 'Oswald', sans-serif;" href="${contextPath}/admin/newproduct">Manage Products</a></li>
        <li><a style="color:white; font-size: 18px; font-weight: bold; font-family: 'Oswald', sans-serif;" href="${contextPath}/admin/viewusers">View Users</a></li>

      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<div class="container">
                    <div class="row-fluid" style="text-align: center;"><h2><div style="font-family: 'Oswald', sans-serif; font-weight: bold; color:#FFAE19;">Top clients</div></h2><br></div>
                    <div class="row-fluid">
                    <table id="topclients" class="table table-striped table-bordered" cellspacing="0" width="100%">
				<thead>
					<tr>
						<th> ID</th>
						<th>Full Name</th>
						<th>Email</th>
						<th>Address</th>
						<th>Town</th>
						<th>Postal Code</th>
                                                <th>Money Spent</th>
					</tr>
				</thead>

				<tfoot>
					<tr>
						<th> ID</th>
						<th>Full Name</th>
						<th>Email</th>
						<th>Address</th>
						<th>Town</th>
						<th>Postal Code</th>
                                                <th>Money Spent</th>
					</tr>
				</tfoot>

				<tbody>
					<c:forEach var="row" items="${result.rows}">
<tr>

<td><c:out value="${row.cust_no}"/></td>
<td><c:out value="${row.cust_name}" /></td>
<td><c:out value="${row.email}"/></td>
<td><c:out value="${row.street}"/></td>
<td><c:out value="${row.town}"/></td>
<td><c:out value="${row.post_code}"/></td>
<td><c:out value="${row.Spend}"/></td>
</tr>
</c:forEach>
				</tbody>
			</table>
                    </div>
   </div>     
    </div>
  
</body>
</html>